<template>
  <view class="graphics-back">
    <text class="graphics-Title">添加垃圾桶以下信息</text>
    <!-- <textarea
      placeholder="为了更好获得医生帮助,请尽可能详细描述病情"
      maxlength="300"
      placeholder-class="textarea-color"
      :auto-focus="true"
      v-model="submitData.illness"
    /> -->
  </view>
  <view class="graphics-back xinguan-flex">
    <text>垃圾桶名称</text>
    <input v-model="model" class="input" type="text" placeholder="绑定地址" />
  </view>


 





  <!-- 提交 -->
  <view style="height: 300rpx"></view>
  <view class="submit">
    <text @click="canCel">取消</text>
    <text @click="subMit">提交</text>
  </view>
</template>

<script setup lang="ts">
import { onMounted, ref, reactive } from "vue";

import { onShow } from "@dcloudio/uni-app";

onShow(() => {

});
let model = ref()
let value3 = ref(true);
function swichchange(){
	value3.value = !value3
}
// 是否重复
let reminderChecked = ref(false)
function onButtonClick(){
	reminderChecked.value = !reminderChecked.value
}

// 选择开始
function changeDate(event: { detail: { value: string } }) {
  submitData.startime = event.detail.value;
}
// 选择开始
function changeDate2(event: { detail: { value: string } }) {
  submitData.endtime = event.detail.value;
}
// 是否需要指导用药
function checkboxChange(event: { detail: { value: string[] } }) {
	console.log(event);
	let checkboxValue:any = event.detail.value
   if (submitData.guide.includes(checkboxValue)) {
          // 如果存在，说明用户取消了选择，从数组中移除
          const index = submitData.guide.indexOf(checkboxValue);
          submitData.guide.splice(index, 1);
        } else {
          // 如果不存在，说明用户选择了该项，将其添加到数组中
          submitData.guide.push(checkboxValue);
        }
}

// 选择就诊人
function choosePatient() {
  uni.navigateTo({
    url: "/pages/my-service/my-patient/my-patient",
  });
}

// 监听选择的就诊人
let name = ref("");



// 待提交数据
let submitData = reactive<any>({

  illness: "",
  guide: [],
  ins_report: [],
  patient_id: "",
  startime:"",
  endtime:"",
  ypnums:"",
  way:"",
  ypname:"",
});

// 取消
function canCel() {
  uni.navigateBack({ delta: 1 });
}

// 提交
type Resobj = {
  statusCode: number;
};
async function subMit() {
 //  uni.showLoading({ title: "提交中", mask: true });
 console.log(user_data.value.id,'user_data.id');
  const sbdate ={
	  ypname:submitData.ypname,
	  timesplit:submitData.guide[0][0],
	  istimeflag:submitData.ins_report[0],
	  starttime:submitData.startime,
	  endtime:submitData.endtime,
	  ypnums:submitData.ypnums,
	  userid:user_data.value.id,
	  way:submitData.way
  }
  const res:any = (await RequestApi.addYP(sbdate));
  if (res.statusCode == 200) {
    uni.showToast({ title: "提交成功", icon: "none", duration: 1000 });
	setTimeout(()=>{
		 uni.navigateTo({
		 	url:'/pages/addsucecss/index'
		 })
	},500)
  }

}
</script>

<style>

.radio-group {
  display: flex;
  flex-direction: column;
}

.radio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10rpx;
  padding: 10rpx;
  border: 1px solid #ddd;
  border-radius: 5rpx;
}

.left {
  flex: 1;
}

.right {
  margin-left: 10rpx;
}
.p-2{
	padding: 10rpx 0;
}
page {
  background-color: #fafafa;
}
.graphics-back {
  background-color: #ffffff;
  margin: 20rpx;
  padding: 20rpx;
  border-radius: 10rpx;
}
.graphics-Title {
  font-size: 35rpx;
  font-weight: bold;
  display: block;
  padding-bottom: 20rpx;
}
textarea {
  width: 100%;
  height: 250rpx;
}
.textarea-color {
  color: #00c8c8;
}
/* 上传图片 */
.pat-image {
  display: flex;
  flex-wrap: wrap;
}
.pat-image view {
  width: calc(33.3% - 5rpx * 2);
  height: 200rpx;
  margin: 5rpx;
}
.pat-image image {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 7rpx;
}
.upload-Image {
  position: relative;
}
.upload-Image image:nth-child(2) {
  width: 30rpx !important;
  height: 30rpx !important;
  position: absolute;
  top: 0;
  right: 0;
}
/* 选择就诊人 */
.patient-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.patient-view image {
  width: 120rpx;
  height: 120rpx;
}
.patient-view text:nth-child(2) {
  flex: 1;
  padding: 0 50rpx;
  font-weight: bold;
}
.patient-view text:nth-child(3) {
  color: #2c76ef;
}
</style>
